package org.codeart.broker.example02;

/**
 * 中介机构
 */
public class MediatorStructure extends Mediator {

    // 中介知晓房东和房客的信息
    private HouseOwner houseOwner;

    // 房客
    private Tenant tenant;

    public HouseOwner getHouseOwner() {
        return houseOwner;
    }

    public void setHouseOwner(HouseOwner houseOwner) {
        this.houseOwner = houseOwner;
    }

    public Tenant getTenant() {
        return tenant;
    }

    public void setTenant(Tenant tenant) {
        this.tenant = tenant;
    }

    @Override
    public void contact(String message, Person person) {
        // 如果是房东 则房客获得信息
        if (person == houseOwner) {
            tenant.getMessage(message);
        } else { // 房客获得信息
            houseOwner.getMessage(message);
        }
    }
}
